package com.zx.email.mapper;

import Email.Dto.EmailDto;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface EmailMapper {
    @Select("select * from emails where company_id = #{companyId}")
    List<EmailDto> findAllByCompanyId(@Param("companyId") Integer companyId);

    @Select("select * from emails where user_id = #{userId}")
    List<EmailDto> findAllByUserId(@Param("userId") Integer userId);

    @Insert("insert into emails (subject,company_id,user_id,email,status) " +
            "values (#{subject},#{companyId},#{userId},#{email},#{status})")
    void sendEmail(EmailDto emailDto);

    @Update("update emails set status = 1 where id = #{id}")
    void setRead(@Param("id") Integer id);
}
